package com.im.util;

import com.im.common.ClientLinkInfo;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: szw
 * @Date: 2021/5/24 10:35
 */
public class Test {
    private static volatile Map<String, String> MANAGER = new ConcurrentHashMap<>();
    public static void main(String[] args) {
        int j = 1;
        ExecutorService pool = Executors.newFixedThreadPool(8);
        try {
            for(int i = 1;i<=10000;i++){
                MANAGER.put(j + "", "222");
                j ++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            pool.shutdown();
        }
        while (Thread.activeCount() > 2)  //保证前面的线程都执行完（执行main方法时，idea会启动两条线程，eclipse没有: > 1）
            Thread.yield();
        System.out.println("map中的属性数量="+MANAGER.size());
    }
}
